##########################################
## Copyright 2012-2013 Ceruti Francesco & contributors
##
## This file is part of LiSP (Linux Show Player).
##########################################

import subprocess
import re
import hashlib


def createGradient(color_1, color_2='rgb(170, 170, 170)'):
    return 'qlineargradient(spread:pad, x1:1, y1:1, x2:1, y2:0, stop:0 ' + color_1 + ', stop:1 ' + color_2 + ');'


def systemVolume():
    return re.findall('[0-9]{0,3}%', subprocess.getoutput('amixer sget Master'))[0]


def setSystemVolume(volume):
    subprocess.getoutput('amixer sset Master ' + str(volume))


def md5sum(filename):
    md5 = hashlib.md5()
    with open(filename, 'rb') as f:
        for chunk in iter(lambda: f.read(128 * md5.block_size), b''):
            md5.update(chunk)
    return md5.hexdigest()


class Clipboard:
    clip = None


class Flags:
    flags = {}
